#ifndef	COMMON_H
#define	COMMON_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <math.h>
#include <errno.h>

#include "link.h"
#include "type.h"
#include "pt_jt808.h"
#include "re_chck.h"
#include "db_dat.h"
#include "mysql_fun.h"
#include "msg_assem.h"
#include "termlMsg_handle.h"
#include "platfMsg_handle.h"
#include "platfMsg_analy.h"

#define BUF_SIZE        512
#define MSG_ENC_FLAG    (1 << 13)

#define	FALSE			0
#define COM_ACK_SUCCESS		0
#define COM_ACK_FAIL		1
#define COM_ACK_INVALID		2
#define COM_ACK_UNSUPPORT	3

#define NAME_FIFO_1	"./file/unique_fifo_1th"
#define NAME_FIFO_2	"./file/unique_fifo_2nd"


#define	E(fmt, args...)	\
		fprintf(stderr, "%s - %s - %d"fmt"\n", __FILE__, __func__, __LINE__, ##args);
#define D(fmt, args...)	\
		fprintf(stdout, "%s - %s - %d"fmt"\n", __FILE__, __func__, __LINE__, ##args);

#define IS_FLAG_BIT_SET(flag, bit)	((flag >> bit)&0x01)
#define FLAG_BIT_SET(flag, bit)		do{(flag |= 0x01 << bit);}while(0)
#define FLAG_BIT_CLR(flag, bit)		do{(flag &= ~(0x01 << bit));}while(0)

extern INSTALL_ARGS_STR g_installArgs;// p_installArgs;
extern VEHICLE_ARGS_STR g_vehicleArgs;
extern SET_ARGS_STR set_argStr;

INT32 assign_jt808msg(JT808_MSG_PKG *pMsg, INT8 *pDat, INT32 datLen);
INT32 send_ack_msg(INT32 sfd, UINT8 *pMsg, INT32 msgLen);
INT32 msg_analyze(JT808_MSG_PKG *pJt808, INT32 sfd);

#endif /* common.h*/
